#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/sched.h>
#include <linux/pid.h>

/*
	模块的初始化; lkp_init(); 
	 */
static int print_pid(void)
{
	struct task_struct *task, *p; 
	struct list_head *pos; 
	int count = 0; 
	printk("Hello,World enter begin:\n"); 
	task = &init_task; 
	list_for_each(pos,&task->tasks)
	{
		p = list_entry(pos,struct task_struct,tasks); 
		count++; 
		printk("%d --> %s\n", p->pid, p->comm); 
	}
	printk("the number of the process is:%d\n",count); 
	printk("=============\n"); 
	printk("%d\n",current_thread_info()->task->pid); 
	printk("%d\n",current->comm); 
	printk("================\n"); 
	struct task_struct *mytask; 
	/*
	do_each_pid_task(1,PIDTYPE_PGID,mytask)
		printk("%d -> %s",mytask->pid,mytask->comm); 
		*/
}

static int __init lkp_init(void)
{
	printk("hello,world\n"); 
	print_pid(); 
	return 0; 
}


/*
	 模块的退出和清理; 
	 */

static void __exit lkp_exit(void)
{
	printk("Good Bye\n"); 
}

module_init(lkp_init); 
module_exit(lkp_exit); 

/*
	模块的代码许可; 
	 */
MODULE_LICENSE("GPL"); 
